找传奇、传世资源到传世资源站!

winform 登陆,修改简单功能实现,带数据库

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

winform 登陆,修改简单功能实现,带数据库 Windows系统编程-第1张
winform 登陆,修改简单功能实现,带数据库 Windows系统编程-第2张
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Configuration;using System.Collections;using System.Data.SqlClient;using System.Threading;namespace JL{ public partial class Login : Form { public Login() { InitializeComponent(); } private void Login_Load(object sender, EventArgs e) { DateTime dt = System.DateTime.Now; lab_systemtime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt); timer1.Start(); this.FormClosed = new FormClosedEventHandler(Login_FormClosed); } void Login_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } private void btn_exit_Click(object sender, EventArgs e) { if ((MessageBox.Show("你确定要退出计量系统吗?", "提示:", MessageBoxButtons.OKCancel)).ToString().Equals(MessageBoxButtons.OK.ToString())) { Application.Exit(); } } private void btn_login_Click(object sender, EventArgs e) { string suserid = this.txt_yhbm.Text.ToString().Trim(); string userkl = this.txt_kl.Text.ToString().Trim(); if (suserid == string.Empty) { MessageBox.Show("用户名不存在!", "登录失败!"); return; } string constring = ConfigurationManager.ConnectionStrings["connString"].ConnectionString.ToString(); SqlConnection conn = new SqlConnection(constring); if (conn.State == ConnectionState.Closed) { conn.Open(); } string sql = "select userid,username from T_USERINFO where userid='" suserid "' and userpass='" userkl "'"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds); string _userName = ""; if (ds.Tables[0].Rows.Count == 1) { _userName = ds.Tables[0].Rows[0][1].ToString(); userInfo.userId = suserid; userInfo.userName = _userName; userInfo.userPassWord = userkl; //ProBar pb = new ProBar(); //pb.Show(); formmain main = new formmain(); main.Show(); this.Hide(); conn.Close(); } else { this.txt_kl.Text = ""; MessageBox.Show("您输入的密码不正确,请重新输入","提示"); } } private void timer1_Tick(object sender, EventArgs e) { DateTime dt = System.DateTime.Now; lab_systemtime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复